<?php if(!defined('HOST'))die('not access');?>
<script >
    var c;
    $(document).ready(function(){
        {params};
        var type = params.type;
        var puid = params.puid;
        var comid = params.comid;
        var proxygov = params.proxygov;
        var sdate = params.sdate;
        var edate = params.edate;
        if(puid == undefined) puid = '';
        if(type == undefined) type = '';
        if(comid == undefined) comid = '';
        if(proxygov == undefined) proxygov = '';
        if(sdate == undefined) sdate = '';
        if(edate == undefined) edate = '';
        var a = $('#veiw_{rand}').bootstable({
            tablename:'zbcg_new_info',celleditor:true,sort:'id',dir:'desc',modedir:'{mode}:{dir}',params:{},fanye:true,
            url:js.getajaxurl('getProjectInfoList','{mode}','{dir}',{'utype':1,'comid':comid,'type':type,'puid':puid,'proxygov':proxygov,'sdate':sdate,'edate':edate}),fanye:true,
            columns:[{
                text:'单位',dataIndex:'companyname'
            },{
                text:'项目名称',dataIndex:'name'
            },{
                text:'批准书文号',dataIndex:'projecticp'
            },{
                text:'批准书获得时间',dataIndex:'proicptime',
            },{
                text:'采购类别',dataIndex:'type'
            },{
                text:'采购方式',dataIndex:'buymode'
            },{
                text:'预算金额（元）',dataIndex:'budget'
            },{
                text:'中标金额',dataIndex:'zbmoney'
            },{
                text:'代理机构',dataIndex:'proxygov'
            },{
                text:'报名单位情况',dataIndex:'signupcompany'
            },{
                text:'公告时间',dataIndex:'proclamationdate'
            },{
                text:'开标时间',dataIndex:'startbiddate'
            },{
                text:'完标时间',dataIndex:'wbtime'
            },{
                text:'中标单位',dataIndex:'zbcompany'
            },{
                text:'合同是否签订',dataIndex:'issignagreement'
            },{
                text:'备注',dataIndex:'gathernote'
            },{
                text:'项目负责人',dataIndex:'projecterName'
            }],
            rendertr:function(d){
                var s = '';
                if(d.level==2)s='style="color:red"';
                return s;
            }
        });

        c = {
            delss:function(){
                a.del({url:js.getajaxurl('dellog','{mode}','{dir}'),checked:true});
            },
            search:function(){
                var s=$('#name_{rand}').val();
                var type = $("#type_{rand}").val();
                var sdate=$('#search_sdate_{rand}').val();
                var edate=$('#search_edate_{rand}').val();
                var comid=$('#unit_{rand}').val();
                var projectadminer=$('#projectadminer_{rand}').val();

                a.setparams({name:s,sdate:sdate,edate:edate, type:type, projectadminer:projectadminer, comid:comid},true);
            },
            daochu:function(){
                a.exceldown();
            },
        };
        js.initbtn(c);
    });
</script>


<div>
    <table>
        <tr>
            <td nowrap style="width: 1%;min-width:100px;padding-left:10px;">
                <select id="unit_{rand}" class="form-control" >
                    <option value="">委托单位</option>
                </select>
            </td>
            <td nowrap style="width: 1%;padding-left:10px;">
                项目时间：
                <input onclick="js.datechange(this,'date')" value="" class="inputs datesss" inputtype="date" readonly="" name="search_sdate" id="search_sdate_{rand}" style="width:110px">
                <input onclick="js.datechange(this,'date')" value="" class="inputs datesss" inputtype="date" readonly="" name="search_edate" id="search_edate_{rand}" style="width:110px">
                <span>&nbsp;&nbsp;</span>
                <button class="btn" id="t_year_{rand}" type="button">年</button>
                <button class="btn" id="t_season_{rand}" type="button">季</button>
                <button class="btn" id="t_month_{rand}" type="button">月</button>
            </td>
            <td nowrap style="width: 5%;padding-left:10px;">
                <span>&nbsp;&nbsp;</span>
                <button class="btn btn-default" click="search" type="button">检索</button>
            </td>
        </tr>
    </table>
</div>
<div class="blank10"></div>
<div id="veiw_{rand}"></div>
<script>
    var date=new Date;
    var y = date.getFullYear()
    $('#search_sdate_{rand}').val(y+'-01-01');

    $(document).ready(function(){
        loadProjectadminer();
        var date = new Date();
        var year = date.getFullYear();
        var month = date.getMonth();
        var month = month + 1;
        if(month.toString().length == 1) {
            month = '0' + month;
        }
        var day = date.getDate();
        $("#t_year_{rand}").click(function(){
            var sdate=$('#search_sdate_{rand}').val(year+'-01-01');
            var edate=$('#search_edate_{rand}').val(year+'-12-31');
        });
        $("#t_season_{rand}").click(function(){
            stime = '';
            etime = '';
            switch(true) {
                case (month <= 3):
                    stime = year+'-01-01';
                    etime = year+'-03-31';
                    break;
                case (3 < month <= 6):
                    stime = year+'-04-01';
                    etime = year+'-06-30';
                    break;
                case (6 < month <= 9):
                    stime = year+'-07-01';
                    etime = year+'-09-30';
                    break;
                case (9 < month <= 12):
                    stime = year+'-10-01';
                    etime = year+'-12-31';
                    break;
            }
            var sdate=$('#search_sdate_{rand}').val(stime);
            var edate=$('#search_edate_{rand}').val(etime);
        });
        $("#t_month_{rand}").click(function(){
            var lastDay= new Date(year,month,0).getDate();
            var sdate=$('#search_sdate_{rand}').val(year+'-'+month+'-01');
            var edate=$('#search_edate_{rand}').val(year+'-'+month+'-'+lastDay);
        });
    });
    function loadProjectadminer(){
        $.ajax({ url: "./index.php?a=getCompanyList&m=main&d=report&ajaxbool=true", success: function(obj){
                var ccc ="<option value=''>委托单位</option>";
                obj = JSON.parse(obj);
                data = obj.rows;
                for(i=0;i<data.length;i++){
                    ccc += "<option value='"+data[i].id+"'>"+data[i].name+"</option>";
                };
                $('#unit_{rand}').html(ccc);
            }});
    }
</script>